package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 联系人枚举类
 *
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/14 15:37
 * @since v1.0
 */
@Getter
public enum ListProductEnum {
    // 联系人模板设置界面展示字段
    NAME("text_1", "enum.listProduct.attrName.name", "name", FieldTypeEnum.TEXT.getType()),
    CONTRACT_NO("text_2", "enum.listProduct.attrName.contract_no", "contractNo", FieldTypeEnum.TEXT.getType()),
    SPECIFICATION("text_3", "enum.listProduct.attrName.specification", "specification", FieldTypeEnum.TEXT.getType()),
    PRODUCT_NUM("num_1", "enum.listProduct.attrName.product_num","productNum",FieldTypeEnum.NUM.getType()),
    ;
    /**
     * 英文名称
     */
    private String attr;
    /**
     * 中文名称
     */
    private String attrName;
    /**
     * 对应saas中的attr
     */
    private String saasAttr;
    /**
     * 字段类型，详见
     *
     * @see FieldTypeEnum
     */
    private Integer fieldType;


    ListProductEnum(String attr, String attrName, String saasAttr, Integer fieldType) {
        this.attr = attr;
        this.attrName = attrName;
        this.saasAttr = saasAttr;
        this.fieldType = fieldType;
    }

    /**
     * 获取全部枚举
     *
     * @return List<ListProductEnum>
     */
    public static List<ListProductEnum> getAllEnum() {
        List<ListProductEnum> list = new ArrayList<>();
        for (ListProductEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }
}
